<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Stasiun extends CI_Controller {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model('Model_stasiun');
		$this->load->library('session');
		$this->data['head'] = $this->load->view('head','',true);
		$this->data['foot'] = $this->load->view('foot','',true);
	}
	
	public function index()
	{
		if($this->session->userdata('stasiun_view') == 'list' )
		{
			$this->listview();
		}
		else
		{
			$this->mapview();
		}
	}
	
	public function mapview()
	{
		$this->session->set_userdata('stasiun_view', 'map');
		$this->data['center'] = $this->Model_stasiun->posisi_tengah();
		$this->data['table'] = $this->Model_stasiun->get_all();
		$this->load->view('melihat_stasiun',$this->data);
	}
	
	public function listview()
	{
		$this->session->set_userdata('stasiun_view', 'list');
		$this->data['table'] = $this->Model_stasiun->get_all();
		$this->load->view('melihat_stasiun_list',$this->data);
	}
	
	public function detail()
	{
		$id = $this->input->get('id',true);
		$this->data['detail'] = $this->Model_stasiun->get_one($id);
		$this->load->view('detail_stasiun',$this->data);
	}
	
}
